﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
using FSS.Core.Util;
using FSS.Core.Controls;
using FSS.BLL.Services;
using FSS.BLL.Entities;

namespace SalesManagement.Modules.Purchase
{
    public partial class VoucherOutReturnList : BasePage
    {
        public VoucherOutReturnList()
            : base(SCREENS.VOUCHEROUTRETURNLIST)
        {

        }
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        [DirectMethod]
        public void DocumentReady()
        {
            BindingWareHouse();
            BindingProvider();
            SearchDocument(1);
        }
        [DirectMethod]
        public void SearchDocument(int pageIndext)
        {
            /*
            VoucherOutService service = VoucherOutService.GetInstance();
            VoucherOutEntity Parramter = new VoucherOutEntity();
            if (!string.IsNullOrEmpty(txtVoucherNo.Text))
                Parramter.VoucherOutNo = txtVoucherNo.Text;
            if (dfDateFrom.SelectedValue != null)
                Parramter.FromDate = dfDateFrom.SelectedDate;
            if (dfDateTo.SelectedValue != null)
                Parramter.ToDate = dfDateTo.SelectedDate;
            int ProviderID = Format.ConvertToInt(cbProvider.SelectedItem.Value);
            if (ProviderID > 0)
                Parramter.CustomerId = ProviderID;

            if (nfTotalAmount.Value != null)
                Parramter.TotalAmount = (decimal)nfTotalAmount.Value;
            IList<VoucherOutEntity> resul = service.VoucherOutReturnSearchData(Parramter);
            if (resul == null)
                return;
            stVoucherOutReturnList.DataSource = resul;
            stVoucherOutReturnList.DataBind();
             * */
        }
        [DirectMethod]
        public void SelectionChange(int MasterID)
        {
            //VoucherOutDetailService service = VoucherOutDetailService.GetInstance();
            //IList<VoucherOutDetailEntity> resul = service.GetAllDetailByMasterID(MasterID);
            //if (resul != null)
            //    stVoucherOutReturnDetail.DataSource = resul;
            //stVoucherOutReturnDetail.DataBind();
        }
        #region binding data
        /// <summary>
        /// Gan nha cung cap
        /// </summary>
        private void BindingProvider()
        {
            ObjectService service = ObjectService.GetInstance();
            IList<ObjectEntity> Resul = service.GetAllProvider();
            Resul.Insert(0, new ObjectEntity
            {
                ObjectId = -1,
                ObjectName = "Tất cả"
            });
            stProvider.DataSource = Resul;
            stProvider.DataBind();
            cbProvider.SelectedIndex = 0;
        }
        private void BindingWareHouse()
        {
            WareHouseService service = WareHouseService.GetInstance();
            IList<WareHouseEntity> Resul = service.LoadAll();
            Resul.Insert(0, new WareHouseEntity
            {
                WarehouseId = -1,
                WarehouseName = "Tất cả"
            });
            stWareHouse.DataSource = Resul;
            stWareHouse.DataBind();
            cbWareHouse.SelectedIndex = 0;
        }
        #endregion
    }
}
